#include "MyClass.h"
#include <QApplication>
#include <QDebug>
#include <QMetaProperty>

void lose(QObject *obj, const char *property) {
    const QMetaObject *meta = obj->metaObject();

#if 0
    int count = meta->propertyCount();
    qDebug() << count;
    for (int i = 0; i < count; i++) {
        QMetaProperty metaProperty = meta->property(i);
        qDebug() << metaProperty.name();
    }
#endif
    int idx = meta->indexOfProperty(property);
    QMetaProperty metaProperty = meta->property(idx);
    int currentVal = metaProperty.read(obj).toInt();
    qDebug() << currentVal;

    metaProperty.write(obj, -100);
}


int main(int argc, char *argv[]) {
    MyClass myClass;
    lose(&myClass, "health");

    return 0;
}
